<?php

class Junction_Mapping_ManyToMany extends Association{
	
	private $_classname;
	
	private $_joinTable;
	
	private $_columns;
	
	public function __construct($classname, $table) {
		$this->_classname = $classname;
		$this->_joinTable = $table;
		$this->_columns = array();
	}
	
	/**
	 * @return String
	 */
	public function getClassname() {
		return $this->_classname;
	}
	
	/**
	 * @return String
	 */
	public function getJoinTable() {
		return $this->_joinTable;
	}
	
	/**
	 * @return Iterator over the columns to join on
	 */
	public function getColumns($table) {
		return new ArrayIterator($this->_columns[$table]);
	}
	
	/**
	 * @return Iterator over the columns to join on
	 */
	public function getTables($table) {
		return new ArrayIterator($this->_columns);
	}
	
	/**
	 * @param String $column
	 */
	public function joinOn($column, $table) {
		if (!$this->_columns[$table])
			$this->_columns[$table] = array();
		$this->_columns[$table][] = $column;
	}
}
?><?php

?>